<html>
<head><meta charset="utf-8"><title>Meaning of `type_length_limit` · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html">Meaning of `type_length_limit`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="186009222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009222">(Jan 18 2020 at 19:47)</a>:</h4>
<p>I got a few errors that instructed me to increase my <code>type_length_limit</code> to <code>1394658</code>. What is the unit of this setting? Should I be worried about running into this soft-limit?</p>



<a name="186009359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zexbe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009359">(Jan 18 2020 at 19:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> <a href="https://github.com/rust-lang/rust/blob/master/src/librustc/middle/recursion_limit.rs" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/middle/recursion_limit.rs">https://github.com/rust-lang/rust/blob/master/src/librustc/middle/recursion_limit.rs</a><br>
It looks like the default is 1048576</p>



<a name="186009416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009416">(Jan 18 2020 at 19:53)</a>:</h4>
<p><span class="user-mention" data-user-id="259133">@Zexbe</span> ok, but what is the unit of this setting? Should I be worried about running into this soft-limit?</p>



<a name="186009489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009489">(Jan 18 2020 at 19:55)</a>:</h4>
<p>The unit is types. So <code>u32</code> has length 1, <code>Vec&lt;u32&gt;</code> has length 2 (<code>Vec&lt;u32&gt;</code> and <code>u32</code>), <code>Vec(u32, u32)&gt;</code> has length 4 (<code>Vec(u32, u32)&gt;</code>, <code>(u32, u32)</code>, <code>u32</code>, `u32).</p>



<a name="186009552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zexbe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009552">(Jan 18 2020 at 19:57)</a>:</h4>
<p>wow, so 1048576 is really big then</p>



<a name="186009598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009598">(Jan 18 2020 at 19:58)</a>:</h4>
<p>Futures code can fairly easily hit this limit (it's after monomorphization and sees through impl trait). You may want to consider strategic use of <code>Pin&lt;Box&lt;dyn Future&gt;&gt;</code>.</p>



<a name="186009600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009600">(Jan 18 2020 at 19:58)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/reference/attributes/limits.html#the-type_length_limit-attribute" target="_blank" title="https://doc.rust-lang.org/nightly/reference/attributes/limits.html#the-type_length_limit-attribute">https://doc.rust-lang.org/nightly/reference/attributes/limits.html#the-type_length_limit-attribute</a></p>



<a name="186009684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009684">(Jan 18 2020 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> hmm; why does the limit exist?</p>



<a name="186009687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009687">(Jan 18 2020 at 20:00)</a>:</h4>
<p>To avoid really slow codegen.</p>



<a name="186009688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009688">(Jan 18 2020 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> thanks for the docs, but I don't see how it correlates to what <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> says:</p>
<blockquote>
<p>maximum number of type substitutions</p>
</blockquote>
<p>How is <code>u32</code> a "type substitution"?</p>



<a name="186009706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009706">(Jan 18 2020 at 20:01)</a>:</h4>
<p>since it's after monomorphization, it doesn't seem to be about preventing non-termination in e.g. the trait system</p>



<a name="186009710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009710">(Jan 18 2020 at 20:01)</a>:</h4>
<p>No, that's what the recursion limit is for.</p>



<a name="186009714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009714">(Jan 18 2020 at 20:01)</a>:</h4>
<p>oh; it's used for traits as well, not just macros</p>



<a name="186009757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009757">(Jan 18 2020 at 20:02)</a>:</h4>
<p>and recursive monomorphizations, etc.</p>



<a name="186009758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009758">(Jan 18 2020 at 20:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> I don't suppose there's an issue about improving the error to guide us to a judicious use of boxing?</p>



<a name="186009766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009766">(Jan 18 2020 at 20:03)</a>:</h4>
<p>is <code>type_length_limit</code> somehow related to the linker and avoiding literally too long type names in debuginfo?</p>



<a name="186009777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009777">(Jan 18 2020 at 20:03)</a>:</h4>
<p>I don't think so. There may be a more general issue about tracking sizes of async futures.</p>



<a name="186009778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009778">(Jan 18 2020 at 20:03)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> is the "really slow codegen" answer insufficient a reason?</p>



<a name="186009827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009827">(Jan 18 2020 at 20:04)</a>:</h4>
<p>ah, I missed matthew's answer</p>



<a name="186009979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009979">(Jan 18 2020 at 20:09)</a>:</h4>
<p>Is there a rough relation of number of types to compilation time? Like, if the default were 1M and I "needed" 100M (made up numbers), what kind of pain would I be feeling?</p>



<a name="186009987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Meaning%20of%20%60type_length_limit%60/near/186009987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Meaning.20of.20.60type_length_limit.60.html#186009987">(Jan 18 2020 at 20:10)</a>:</h4>
<p>/me ponders whether storing generator witnesses out of line to reduce the impact of this would make any sense</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>